import { http } from "@/utils/http";

export type commonResult<T> = {
  code: number;
  msg: string;
  result: T;
};

export type infoType = {
  permissions?: any,
  roleName?: string,
  createdAt?: string,
  id?: number,
}
export type infoTypeList = {
  data: infoType[];
  total: number;
};

const List = '/system/system/v2/manager/roles';
const Url = '/system/system/v2/manager/role';
export const getList = (params?: object) => {
  return http.request<commonResult<infoTypeList>>("get", List, {
    params
  });
};
export const getInfo = (params?: object) => {
  return http.request<commonResult<infoType>>("get", Url, {
    params
  });
};
export const addInfo = (data?: object) => {
  return http.request<commonResult<any>>("post", Url, {
    data
  });
};
export const editInfo = (data?: object) => {
  return http.request<commonResult<any>>("put", Url, {
    data
  });
};
export const deleteInfo = (data?: object) => {
  return http.request<commonResult<any>>("delete", Url, {
    data
  });
};

/** 1.2.3.5 获取所有角色 */
export const getAllRole = (params?: object) => {
  return http.request<commonResult<any>>("get", '/system/system/v2/manager/role-list', {
    params
  });
};
/** 1.2.3.6 获取所有权限 */
export const getAllPermission = (params?: object) => {
  return http.request<commonResult<any>>("get", '/system/system/v2/manager/permissions', {
    params
  });
};